﻿@layout AccountLayout
@page "/admin/register/"
@inject HttpClient Http
@inject NavigationManager _navigationManager
@inject IStringLocalizer<Resource> _localizer

<PageTitle Title="@_localizer["register"]" />

<div class="account-header">
    <h2 class="account-title text-lg-center">@_localizer["welcome-blogifier"]</h2>
</div>

@if (showError)
{
    <div class="account-message -error">@_localizer["register-failed"].</div>
}

@if (model != null)
{
    <EditForm Model="@model" OnValidSubmit="RegisterUser">
        <DataAnnotationsValidator />
        <div class="form-floating form-item">
            <input @bind="model.Email" id="registerEmail" class="form-control" type="email" placeholder="@_localizer["email"]" autofocus>
            <label for="registerEmail">@_localizer["email"]</label>
            <ValidationMessage For="@(() => model.Email)"></ValidationMessage>
        </div>
        <div class="form-floating form-item">
            <input @bind="model.Name" id="registerName" class="form-control" type="text" placeholder="@_localizer["name"]">
            <label for="registerName">@_localizer["name"]</label>
            <ValidationMessage For="@(() => model.Name)"></ValidationMessage>
        </div>
        <div class="form-floating form-item">
            <input @bind="model.Password" id="registerPassword" class="form-control" type="password" placeholder="@_localizer["password"]">
            <label for="registerPassword">@_localizer["password"]</label>
            <ValidationMessage For="@(() => model.Password)"></ValidationMessage>
        </div>
        <div class="form-floating form-item">
            <input @bind="model.PasswordConfirm" id="registerConfirmPassword" class="form-control" type="password" placeholder="@_localizer["confirm-password"]">
            <label for="registerConfirmPassword">@_localizer["confirm-password"]</label>
            <ValidationMessage For="@(() => model.PasswordConfirm)"></ValidationMessage>
        </div>
        <button type="submit" class="btn btn-blogifier btn-block btn-floating">@_localizer["create-admin-account"]</button>
    </EditForm>
}
